// /*
//  * @Author: WanYiMing
//  * @Date:2024-04-07-18:10
//  * @Description:
//  */

using System.Collections;
using UnityEngine;

namespace Code.Utility
{
    public class ScaleUtils
    {
        public static IEnumerator ScaleInAndOut(Transform transform, float scaleAmount, float duration)
        {
            Vector3 originalScale = transform.localScale;
            Vector3 targetScale = originalScale * scaleAmount;

            float time = 0f;
            while (time < duration / 2f)
            {
                time += Time.deltaTime;
                transform.localScale = Vector3.Lerp(originalScale, targetScale, time / (duration / 2f));
                yield return null;
            }

            yield return new WaitForSeconds(0.5f); // 等待0.5秒

            time = 0f;
            while (time < duration / 2f)
            {
                time += Time.deltaTime;
                transform.localScale = Vector3.Lerp(targetScale, originalScale, time / (duration / 2f));
                yield return null;
            }
        }
    }
}